<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div style="color: orange;margin-bottom:20px">{{$t('说明：该功能需要配套领券APP使用。')}}</div>
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item :label="$t('套餐名称')">
              <a-input :placeholder="$t('请输入套餐名称')" v-model="queryParam.name"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">{{$t('查询')}}</a-button>
            </span>
          </a-col>
          <a-col :xl="12" :lg="10" :md="8" :sm="24">
            <div style="text-align:right;">
              <a-button @click="handleAdd" type="primary" icon="plus" style="margin-left: 8px" v-has="'BisThirdGoodsController:add'">{{$t('新增')}}</a-button>
            </div>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->
    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange"
      >
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">无图片</span>
          <img
            v-else
            :src="getImgView(text)"
            height="25px"
            alt=""
            style="max-width: 80px; font-size: 12px; font-style: italic"
          />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
            {{$t('下载')}}
          </a-button>
        </template>
        <template slot="detail" slot-scope="text,record">
          <div>
            <div v-for="(item,i) in record.bisThirdGoodsPackageList" :key="i">{{item.goodsId_dictText+'*'+item.amount}}</div>
          </div>
        </template>
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)" v-has="'BisThirdGoodsController:edit'">{{$t('修改')}}</a>
          <a-divider type="vertical" v-has="'BisThirdGoodsController:edit'" />
          <a-popconfirm :title="$t('确定删除吗?')" @confirm="() => handleDelete(record.id)">
            <a v-has="'BisThirdGoodsController:delete'">{{$t('删除')}}</a>
          </a-popconfirm>
        </span>
      </a-table>
    </div>
    <goods-modal ref="modalForm" @ok="modalFormOk"></goods-modal>
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import GoodsModal from './modules/GoodsModal'

export default {
  name: 'PackageSetting',
  mixins: [JeecgListMixin,mixinDevice],
  components: {
    GoodsModal,
  },
  data() {
    return {
      description: '套餐设置页面',
      // 表头
      columns: [
        {
          title: this.$t('商品名称'),
          align: 'center',
          dataIndex: 'name',
        },
        {
          title: this.$t('限购数量'),
          align: 'center',
          dataIndex: 'limitNum',
        },
        {
          title: this.$t('商品明细'),
          align: 'center',
          dataIndex: 'detail',
          scopedSlots: { customRender: 'detail' }
        },
        {
          title: this.$t('说明'),
          align: 'center',
          dataIndex: 'comment',
        },
        {
          title: this.$t('操作'),
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' },
        },
      ],
      url: {
        list: '/goods/bisThirdGoods/list',
        delete: '/goods/bisThirdGoods/delete',
      },
      dictOptions: {},
      superFieldList: [],
    }
  },
  created() {
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    initDictConfig() {},
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>